# -*- coding:utf-8 -*-
import httpx

client = httpx.Client(http2=True)

headers = {
    'user-agent': 'yuanrenxue.project',
    "Cookie": "sessionid=pwin2ge9j7t9ttj5m15pjwar9m4sj9tc;",
}


# 报错 AttributeError: ENABLE_CONNECT_PROTOCOL 使用下面指令更新 h2 库解决
# pip install --upgrade h2 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
def get_data(page):
    url = f'https://match.yuanrenxue.com/api/match/17?page={page}'
    return client.get(url, headers=headers).json()


def main():
    value_list = []
    for page in range(1, 6):
        res = get_data(page)
        print("res==>", res)
        value_list += [v['value'] for v in res['data']]
    print(value_list)
    print(sum(value_list))


if __name__ == '__main__':
    main()
